﻿using Oblivion.Substructure;

namespace Oblivion.Networking.Packets
{
    public class ServerInfoPacket
    {
        public byte MaxPlayers
        {
            get { return (byte) Program.Configuration.MAX_PLAYERS; }
        }

        public int ProtocolVersion
        {
            get { return Program.Configuration.PROTOCOL_VERSION; }
        }

        public int PlayersOnline
        {
            get { return Kernel.PlayersOnline; }
        }

        public string TargetClientVersion
        {
            get { return Program.Configuration.TARGET_CLIENT_VERSION; }
        }

        public string MOTD
        {
            get { return Program.Configuration.MOTD; }
        }

        public string info()
        {
            //§1 is some weird thing minecraft wants at the start of the packet
            //§b§l is Minecrafts way of saying Cyan & Bold
            return "§1\0" + ProtocolVersion + "\0" +
                   TargetClientVersion + "\0§b§l" +
                   MOTD + "\0" + PlayersOnline +
                   "\0" + MaxPlayers;
        }
    }
}